/* var id = getvl("id");*/
 xinzhengdizhi(3);
 goumai()
 function goumai(){
		$.ajax({
             url: "http://localhost:8080/api/incrementService/WXselectWindowListtype",
			type: "get",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			success: function(data) {
				if(data.success == true) {
					var sss=0;
						var shijian="";
						var start="";
						var qians="";
					$.each(data.data, function(y,m) {
		  var zhengzhi='<div class="dingdan_title">'+m.title+'<span class="zengzhi_time">竞拍结束时间:'+m.endtime+'</span></div>'+
'<div class="zengzhi_wenzi">'+
	'<h4>'+m.subtitle+'</h4>'+
	'<h5>'+m.endtime+'-'+m.starttime+'期</h5>'+
	/*'<h6>(本期广告位共'+sss+'个)</h6>'+*/
'</div>'+
'<div class="zengzhi_ren">截止目前本期竞拍人数<em>'+m.numberofbidders+'</em>人</div>'+
'<div class="zengzhi_chu">'+
	'<div class="zengzhi_chujia clearfix">'+
		'<input type="number" id="chujia'+m.id+'" placeholder="拍价位&yen;'+m.price+'"/>'+
		'<input type="button" onclick="gotozhifu('+m.id+')"  value="出价" />'+
	'</div>'+
	'<div>'+
		'<p>~只有在截止日期前完成付款才视为有效竞价</p>'+
		'<p>~根据出价获得广告排位，价格越高排位越靠前</p>'+
		'<p>~没能获得广告位的客户，系统将自动退款到账户</p>'+
	'</div>'+
'</div>'+
'<div class="zengzhi_img">'+
	'<img src="'+m.imgUrl+'" />'+
'</div>';
					$("#zhengzhi").append(zhengzhi);
					});
		
				} else if(data.code == 'OVERTIME') {
					var thisUrl = window.location.href;
					//alert(thisUrl);
					if(thisUrl.indexOf('1.0.0denglu.html') <= -1) {
						top.window.location.href = "../1.0.0denglu.html";
					}
				} else {
					if(data.msg != '空数据') {
						alert(data.msg)
					} else {
						$('#thiscount').text(0);
					}
				}
			},
			error: function() {
				alert("error");
			}
		});
 	
 }


var chujia="";
var inds="";
	
	 function gotozhifu(te){
	 	
	  chujia=$("#chujia"+te).val();
	  alert(chujia)
	 	if(chujia!=""){
   		$.ajax({ /*urlcore +*/
		url: "http://localhost:8080/api/incrementService/selectvalueadded?id="+te,
		type: "get",
		dataType: 'json',
		contentType: "application/json;charset=utf-8",
		success:function(data){
			if (data.success == true) {
				inds=te;
				alert(te)
				   callpay();
			}
		},
		error:function() {
			/* Act on the event*/ 
			alert("error");
		}
	});	
	}
   }


 function callpay(){
		if (typeof WeixinJSBridge == "undefined"){
			    if (document.addEventListener){
		document.addEventListener('WeixinJSBridgeReady', zhifuweixin,false);
			    }else if (document.attachEvent){
        document.attachEvent('WeixinJSBridgeReady', zhifuweixin);
		document.attachEvent('onWeixinJSBridgeReady', zhifuweixin);
			    }
			    }else{
			        zhifuweixin();
			    }
			}
 


function zhifuweixin(){
	              if(inds!=""&&chujia!=""){
				$.ajax({
					url: urlcore+"/api/pay/balanceMoney?incrementServiceId="+inds+"&cashMoney="+chujia,
					type: "get",
					dataType: 'json',
					contentType: "application/json;charset=utf-8",
					success:function(data){		
					var d = data.data;
					 WeixinJSBridge.invoke(
					    'getBrandWCPayRequest',
					    {
				           "appId":d.appId,    
				           "timeStamp":d.timeStamp,        
				           "nonceStr":d.nonceStr, 
				           "package":d.package,     
				           "signType":"MD5",        
				           "paySign":d.paySign 
				       },
					    function (res){
					         if(res.err_msg == "get_brand_wcpay_request:ok" ) {
					         	   alert("支付成功");
					         }else{
					         	alert("支付失败");
					         }
					    });
				},
					error:function() {
						/* Act on the event */
						alert("error");
					}
				});	
				}
	}
        
